class TongSdk {
    ws = null;
    appid = null;
    u_name=null;
    _fn_error = function (e) {
    }
    // 维护一个本地的聊天群组
    _local_connect = [];
    // 好友的这些自行维护
    constructor(url, your_app_id) {
        this.appid = your_app_id;
        this.ws = new WebSocket(url + "?appid=" + your_app_id)
        this.ws.onerror = e => this._fn_error(e)
    }

    onError(callback) {
        this.ws.onerror = e => callback(e)
    }

    onMessage(callback) {

        this.ws.onmessage = e =>{
            let _resp = JSON.parse(e.data);
            if (_resp.type===6){
                this.appid =_resp.uuid;
                this.u_name = _resp.u_name;
            }
            callback(_resp);
        }
    }

    // 点对点单聊
    sendSingle(your_uuid, other_uuid) {

    }

    // 发送到所有用户
    sendBroadcast() {

    }

    // 发送到群组聊天
    sendGroup() {

    }
}